import * as echarts from '../ec-canvas/echarts.js';

Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    ec: {
      lazyLoad: true
    },
  },

  ready() {
    this.ecComponent = this.selectComponent('.ec-charts');
    this.init();
  },

  /**
   * 组件的方法列表
   */
  methods: {
    init() {
      this.ecComponent.init((canvas, width, height) => {
        const chart = echarts.init(canvas, null, {
          width: width,
          height: height
        });
        canvas.setChart(chart);
        var option = {
          color: ["#32C5E9", "#37A2DA", "red"],
          series: [{
            type: 'pie',
            label: {
              normal: {
                position: 'inner'
              }
            },
            center: ['50%', '50%'],
            radius: [0, '60%'],
            data: [{
              value: 10,
              name: '已用'
            }, {
              value: 53,
              name: '可用'
            }, {
              value: 37,
              name: '失效'
            }]
          }]
        };
        chart.setOption(option);
        this.chart = chart;
        return chart;
      });
    }
  }
})